package com.effectiv.gooruda.rest.api.controller;

import java.util.Date;
import java.util.List;

import javax.validation.Valid;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.effectiv.gooruda.rest.api.domain.Log;

public interface Sample {

	// yyyy-MM-dd
	@RequestMapping(value = "/findbetween/{start}/{end}", method = RequestMethod.GET)
	public @ResponseBody
	abstract List<Log> findBetween(
			@PathVariable @DateTimeFormat(iso = ISO.DATE) Date start,
			@PathVariable @DateTimeFormat(iso = ISO.DATE) Date end,
			@RequestParam(value = "pageNo", required = false, defaultValue = "0") int pageNo,
			@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize);

	@RequestMapping(value = "/findbylogtext/{text}", method = RequestMethod.GET)
	public @ResponseBody
	abstract List<Log> findByLogText(
			@PathVariable String text,
			@RequestParam(value = "pageNo", required = false, defaultValue = "0") int pageNo,
			@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize);

	@RequestMapping(method = RequestMethod.POST)
	@ResponseStatus(HttpStatus.CREATED)
	public @ResponseBody
	abstract Log save(@Valid @RequestBody Log l);

	@RequestMapping(value = "/findbytype/{type}", method = RequestMethod.GET)
	public @ResponseBody
	abstract List<Log> findByType(
			@PathVariable String type,
			@RequestParam(value = "pageNo", required = false, defaultValue = "0") int pageNo,
			@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize);

	@RequestMapping(value = "/countbytype/{type}", method = RequestMethod.GET)
	public @ResponseBody
	abstract long countByType(@PathVariable String type);

	@RequestMapping(value = "/countbytext/{text}", method = RequestMethod.GET)
	public @ResponseBody
	abstract long countByText(@PathVariable String text);

	@RequestMapping(value = "/countbydaterange/{start}/{end}", method = RequestMethod.GET)
	public @ResponseBody
	abstract long countByDateRange(

	@PathVariable @DateTimeFormat(iso = ISO.DATE) Date start,
			@PathVariable @DateTimeFormat(iso = ISO.DATE) Date end);

}